const inquirer = require('inquirer')

// 模板询问
async function   templateTypeRawlist () {
   return await  inquirer.prompt([ {
    name: 'templateType',
    type: 'list',
    message: '请选择拉取哪个模版',
    choices: [
      { name: 'react模版', value: 'react' },
      { name: 'vue模版', value: 'vue' }
    ],
    }])
  }

  // 日志上报owl询问
  async function   owlConfirm (answers) {
    return await  inquirer.prompt([{
     name: 'owl',
     type: 'confirm',
     message: '是都需要上报日志功能（owl）',
     }],answers)
   }
 
// 默认组件选择
async function  defaultComCheckbox (answers) {
  return await  inquirer.prompt([{
   name: 'defaultCom',
   type: 'checkbox',
   message: "请选择项目所需要的组件库：",
   choices:[
    {
      name: 'Modal',
      value: 'modal',
    },
    {
      name: 'Loading',
      value: 'loading',
    },
   ]
   }],answers)
 }

module.exports.ask = async function () {

  const data ={}

    const {templateType} = await templateTypeRawlist()
    data[templateType] = true

    const {owl} = await owlConfirm()
    data.owl= owl

    const {defaultCom}  = await defaultComCheckbox()

    defaultCom.forEach((item)=>{
      data[item] = true
    })
    console.log('data',data)
    return data
}